//2009/08/10 22:55:25
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

class MagicSquare
{
public:
    int missing(vector <int> square)
    {
		int a = square[0] + square[1] + square[2];
		int b = square[3] + square[4] + square[5];
		int c = square[6] + square[7] + square[8];
		
		return max(max(a,b),c) - min(min(a,b),c) - 1;
    }
};
